﻿@{
    var pts = ((List<DataAccess.DTO.PromoterTodayStatistics>)ViewBag.TS);
    ViewBag.Title = "-首页";
    int i = 1;
}
<div class="row">
    <div class="col-lg-12">
        <div class="row">
            <div class="col-lg-12">
                <div id="content-header" class="clearfix">
                    <div class="pull-left">
                        <ol class="breadcrumb">
                            <li><a href="/">首页</a></li>
                            <li class="active"><span>首页</span></li>
                        </ol>
                        <h1>纵横淘客管理系统</h1>
                    </div>

                </div>
            </div>
        </div>


        @foreach (var item in pts)
        {
            if (item.type == "today")
            {
                <div class="row">
                    <div class="col-lg-3 col-sm-6 col-xs-12">
                        <div class="main-box infographic-box colored emerald-bg">
                            <i class="fa fa-file-text-o"></i>
                            <span class="headline">今日订单</span>
                            <span class="value">@item.ordernumber</span>
                        </div>
                    </div>
                    <div class="col-lg-3 col-sm-6 col-xs-12">
                        <div class="main-box infographic-box colored blue-bg" style="background-color: #55acee !important;">
                            <i class="fa  fa-rmb (alias)"></i>
                            <span class="headline">今日预估佣金</span>
                            <span class="value">@item.estimate</span>
                        </div>
                    </div>


                    <div class="col-lg-3 col-sm-6 col-xs-12">
                        <div class="main-box infographic-box colored red-bg">
                            <i class="fa fa-user-md"></i>
                            <span class="headline">代理数</span>
                            <span class="value">@item.agentcount</span>
                        </div>
                    </div>
                    <div class="col-lg-3 col-sm-6 col-xs-12">
                        <div class="main-box infographic-box colored purple-bg">
                            <i class="fa fa-user"></i>
                            <span class="headline">粉丝</span>
                            <span class="value">@item.usercount</span>
                        </div>
                    </div>

                </div>

            }
            else
            {
                <div class="row">
                    <div class="col-lg-3 col-sm-6 col-xs-12">
                        <div class="main-box infographic-box">
                            <i class="fa fa-file-text-o red-bg"></i>
                            <span class="headline">昨日订单</span>
                            <span class="value red">
                                <span class="timer" data-from="120" data-to="2562" data-speed="1000" data-refresh-interval="50">
                                    @item.ordernumber
                                </span>
                            </span>
                        </div>
                    </div>
                    <div class="col-lg-3 col-sm-6 col-xs-12">
                        <div class="main-box infographic-box">
                            <i class="fa fa-rmb (alias) emerald-bg"></i>
                            <span class="headline">昨日预估</span>
                            <span class="value emerald">
                                <span class="timer" data-from="30" data-to="658" data-speed="800" data-refresh-interval="30">
                                    @item.estimate
                                </span>
                            </span>
                        </div>
                    </div>
                    <div class="col-lg-3 col-sm-6 col-xs-12">
                        <div class="main-box infographic-box">
                            <i class="fa  fa-location-arrow blue-bg"></i>
                            <span class="headline">昨日点击</span>
                            <span class="value green">
                                <span class="timer" data-from="83" data-to="8400" data-speed="900" data-refresh-interval="60">
                                    @item.clicknum
                                </span>
                            </span>
                        </div>
                    </div>
                    <div class="col-lg-3 col-sm-6 col-xs-12">
                        <div class="main-box infographic-box">
                            <i class="fa fa-rmb (alias) yellow-bg"></i>
                            <span class="headline">昨日结算</span>
                            <span class="value yellow">
                                <span class="timer" data-from="539" data-to="12526" data-speed="1100">
                                    @item.income.ToString("#0.00")
                                </span>
                            </span>
                        </div>
                    </div>
                </div>


            }
        }






        <div class="row">
            <div class="col-lg-6">
                <div class="main-box">
                    <header class="main-box-header clearfix">
                        <h2>本月统计</h2>
                    </header>
                    <div class="main-box-body clearfix">
                        <div id="this_month"></div>
                    </div>
                </div>

            </div>
            <div class="col-lg-6">

                <div class="main-box">
                    <header class="main-box-header clearfix">
                        <h2>上月统计</h2>
                    </header>
                    <div class="main-box-body clearfix">
                        <div id="last_month"></div>
                    </div>
                </div>
            </div>
        </div>



        <div class="row">


            <div class="col-lg-4">
                <div class="main-box clearfix">
                    <header class="main-box-header clearfix">
                        <h2>代理排行</h2>
                    </header>
                    <div class="main-box-body clearfix">
                        <ul class="widget-users row">

                            @foreach (var item in (List<DataAccess.DTO.RankingList>)ViewBag.phb)
                            {
                                <li class="col-md-12">
                                    <div class="img">
                                        <img style="width:50px" src="@item.head_img" alt="" />
                                    </div>
                                    <div class="details" style="text-align: right;">

                                        <div class="title">
                                            <a href="#">No.@(i++)</a> - @item.nickname
                                        </div>
                                        <div>
                                            <br />
                                            <span>@item.estimate.ToString("C") </span>
                                        </div>
                                        @*<div class="type">
                                                <div class="progress  progress-2x">

                                                      <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100" style="width: 70%">
                                                        <span class="sr-only">70%</span>
                                                    </div>
                                                </div>
                                            </div>*@
                                    </div>
                                </li>

                            }


                            @*<li class="col-md-12">
                                    <div class="img">
                                        <img src="/img/samples/scarlet.png"  alt="" />
                                    </div>
                                    <div class="details">

                                        <div class="title">
                                            <a href="#">第一名</a> - 徐鑫
                                        </div>

                                        <div class="type">
                                            <div class="progress  progress-2x">
                                                <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100" style="width: 70%">
                                                    <span class="sr-only">70%</span>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </li>*@

                        </ul>
                    </div>
                </div>
            </div>

            <div class="col-lg-8">
                <div class="main-box">
                    <header class="main-box-header clearfix">
                        <h2>代理活跃度</h2>
                    </header>
                    <div class="main-box-body clearfix">
                        <div id="graph"></div>
                    </div>
                </div>
            </div>
        </div>

    </div>
</div>
@section Scripts{
    <script type="text/javascript" src="~/Scripts/sys/lib/common_raw.js"></script>
    <script src="/js/raphael-min.js"></script>
    <script src="/js/morris.js"></script>

    <script>
        $(function ($) {


            graphArea = Morris.Area({
                element: 'graph',
                behaveLikeLine: true,
                data: [
                    { x: '2011 Q1', y: 4, z: 3 },
                    { x: '2011 Q2', y: 2, z: 1 },
                    { x: '2011 Q3', y: 5, z: 4 },
                    { x: '2011 Q4', y: 5, z: 4 }
                ],
                lineColors: ['#ffc107', '#58DDD0'],
                xkey: 'x',
                ykeys: ['y', 'z'],
                labels: ['Y', 'Z'],
                resize: true
            });




        });
        $(function () {

            common.invokeApi(
                "POST",
                "/Home/GetStatistics_List",
                //{ rid: id, rpw1: rpw1, rpw2: rpw2, rname: name },
                null,
                function () { },
                function (data) {
                    if (data.State) {
                        //本月
                        graphLine = Morris.Line({
                            element: 'this_month',
                            data: data.Datas.this_month,
                            lineColors: ['#A9D86E', '#ffc107', '#FF6C60', '#58DDD0', '#9972B5', '#90a4ae'],
                            xkey: ['riqi'],
                            ykeys: ['estimate', 'income'],
                            labels: ['预估收入', '结算收入'],
                            hideHover: 'auto',
                            resize: true,
                            parseTime: false
                        });
                        //上月
                        graphBar2 = Morris.Bar({
                            element: 'last_month',
                            data: data.Datas.last_month,
                            barColors: ['#A9D86E', '#FF6C60', '#f39c12', '#3fcfbb', '#626f70', '#8f44ad'],
                            xkey: ['riqi'],
                            ykeys: ['estimate', 'income'],
                            labels: ['预估收入', '结算收入'],
                            barRatio: 0.4,
                            xLabelAngle: 35,
                            hideHover: 'auto',
                            resize: true
                        });


                    }

                    // window.location.reload();
                    //common.msg(data.Message, 1, function () {
                    //$("#id").val("0");
                    //    $("#rname]").val("");
                    //    $(".md-close").trigger("click");

                    // initAcTable();
                    //});
                },
                function (data) {
                    // common.msg(data.Message, 2, function () { });
                    alert(data.Message);
                },
                function () { }
                );
        })

    </script>
}